#!/bin/sh

# if app not exist
if [ ! -f /bin/crond ]; then
    exit 0
fi

LOG="logger -t cron"

start() {
    CrondEnable=`nvram_get 2860 CrondEnable`
    if [ "$CrondEnable" = "1" ]; then
	$LOG "Starting crontab"
	crond -l 0 -L /var/log/cron.log
    fi
}

stop() {
  $LOG "Stopping crontab"
    killall -q crond
    killall -q -SIGKILL crond
}

case "$1" in
	start)
	    start
	    ;;

	stop)
	    stop
	    ;;

	restart)
	    stop
	    start
	    ;;

	*)
	    echo $"Usage: $0 {start|stop|restart}"
	    exit 1
esac
